﻿using System;
using System.Linq;
using MeetSomeNearbyStranger.DataModels;
using MeetSomeNearbyStrangerWebApi.Models;
using System.Collections.Generic;

namespace MeetSomeNearbyStrangerWebApi.Mappers
{
    public class UsersMapper
    {
        public static User ToUserEntity(UserRegisterModel userModel)
        {
            User userEntity = new User()
            {
                Nickname = userModel.Nickname,
                Age = userModel.Age,
                UserID = userModel.UserID,
                Gender = userModel.Gender,
                Latitude = userModel.Latitude,
                Longitude = userModel.Longitude,
            };

            return userEntity;
        }

        public static ProfileModel ToProfileModel(User entity, string imagePublicLocation)
        {
            ProfileModel userEntity = new ProfileModel()
            {
                Nickname = entity.Nickname,
                Age = entity.Age,
                Gender = entity.Gender,
                Meets = entity.Meets,
                ProfileImage = imagePublicLocation
            };

            return userEntity;
        }

        public static ProfileModel ToProfileModel(User entity, string imagePublicLocation, string status)
        {
            ProfileModel userEntity = new ProfileModel()
            {
                Nickname = entity.Nickname,
                Age = entity.Age,
                Gender = entity.Gender,
                Meets = entity.Meets,
                ProfileImage = imagePublicLocation,
                Status = status
            };

            return userEntity;
        }

        public static UserMediumModel ToUserMediumModel(User entity)
        {
            string pic = null;
            if (entity.ProfileImage != null)
            {
                pic = entity.ProfileImage.ImagePublicLocation;
            }

            return new UserMediumModel()
            {
                Id = entity.Id,
                Age = entity.Age,
                Gender = entity.Gender,
                Meets = entity.Meets,
                ProfileImage = pic,
                Nickname = entity.Nickname
            };
        }

        public static UserShortModel ToUserShortModel(User userEntity)
        {
            string pic = null;
            if (userEntity.ProfileImage != null)
            {
                pic = userEntity.ProfileImage.ImagePublicLocation;
            }

            return new UserShortModel
            {
                Id = userEntity.Id,
                Latitude = userEntity.Latitude,
                Longitude = userEntity.Longitude,
                Nickname = userEntity.Nickname,
                ProfileImage = pic
            };
        }
    }
}